import React from 'react';
import Son from './Son';
import { useState } from 'react';
// 引入context 对象
import contextObj from './context';
const { Provider } = contextObj;
const Father = () => {
    const [nameArr, setNameArr] = useState(['罗贯中', '施耐庵', '吴承恩', '曹雪芹'])
    return (
        <div>
            {/* 使用子组件 */}
            <p>父组件</p>
            <p><button onClick={() => {
                nameArr.push('蒲松龄');
                setNameArr([...nameArr])
            }}>添加作家</button></p>
            <Provider value={nameArr}>
                <Son></Son>
            </Provider>
        </div>
    );
}

export default Father;
